package com.lovi.io_.propertis_;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class Properties02_ {
    public static void main(String[] args) throws IOException {
        String filePath = "Java-03/src/main/resources/mysql.properties";
        //使用Properties 类来读取mysql.properties 文件
        //1. 创建Properties 对象
        Properties pr = new Properties();
        //2. 加载指定配置文件
        pr.load(new BufferedReader(new FileReader(filePath)));
        //3. 把k-v显示控制台
        System.out.println("-------------把k-v显示控制台-------------");
        pr.list(System.out);
        //4. 根据key 获取对应的值
        System.out.println("-------------根据key 获取对应的值-------------");
        System.out.println("user = " + pr.getProperty("user"));
        System.out.println("pwd = " + pr.getProperty("pwd"));
        System.out.println("ip = " + pr.getProperty("ip"));


    }
}
